package com.thinkgem.jeesite.common.db;
 
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
 
/**
 * 多数据源切换
 * @author lj
 *
 */
public class DynamicDataSource extends AbstractRoutingDataSource
{
    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>(); 
        
    @Override 
    protected Object determineCurrentLookupKey() { 
        return getCurrentLookupKey(); 
    } 
   
    public static String getCurrentLookupKey() { 
        return (String) contextHolder.get(); 
    } 
    
   
    public static void setCurrentLookupKey(String currentLookupKey) { 
        contextHolder.set(currentLookupKey); 
    } 
    
    
}